home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
comm1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-19
|
50KB
|
1,661 lines
/***********************************************************************/
/* COMM1.C - Commands A-D */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\comm1.c 1.4 1993/09/01 16:25:34 MH Interim MH $
*/
#include <stdio.h>
#include "the.h"
#include "proto.h"
/*#define DEBUG 1*/
/*-------------------------- external data ----------------------------*/
extern LINE *next_line,*curr_line;
extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern WINDOW *foot,*error_window,*divider;
extern bool error_on_screen;
extern char *rec;
extern unsigned short rec_len;
extern char *cmd_rec;
extern unsigned short cmd_rec_len;
extern char mode_insert; /* defines insert mode toggle */
extern char in_profile; /* indicates if processing profile */
extern char *temp_cmd;
extern char dir_filename[10];
extern char dir_pathname[MAX_FILE_NAME+1];
extern char sp_path[MAX_FILE_NAME+1] ;
extern char sp_fname[MAX_FILE_NAME+1] ;
extern char dir_path[MAX_FILE_NAME+1] ; /* for dir and ls commands */
/*man-start*********************************************************************
COMMAND
add - add blank line
SYNTAX
ADD [n]
DESCRIPTION
The ADD command inserts the specified number of blank lines after
the current_line (if issued from the command line) or after the
focus_line (if issued in the main of prefix windows).
The cursor is positioned in the column corresponding to the first
column not containing a space in the line above.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
DEFAULT
With no parameters, 1 line is added.
SEE ALSO
SOS ADDLINE
STATUS
Complete
**man-end**********************************************************************/
#ifdef PROTO
int Add(char *params)
#else
int Add(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
#define ADD_PARAMS 1
char *word[ADD_PARAMS+1];
char parm[ADD_PARAMS];
unsigned short num_params;
long num_lines;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm1.c: Add");
#endif
/*---------------------------------------------------------------------*/
/* Validate the parameters that have been supplied. The one and only */
/* parameter should be a positive integer greater than zero. */
/* If no parameter is supplied, 1 is assumed. */
/*---------------------------------------------------------------------*/
num_params = param_split(params,word,ADD_PARAMS,WORD_DELIMS,TEMP_PARAM);
if (num_params == 0)
{
num_params = 1;
word[0] = (char *)"1";
}
if (num_params != 1)
{
display_error(1,word[1]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
if (!valid_positive_integer(word[0]))
{
display_error(4,word[0]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
num_lines = atol(word[0]);
post_process_line(CURRENT_VIEW->focus_line);
insert_new_line((char *)"",0,num_lines,get_true_line(),FALSE,FALSE);
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
all - select and display restricted set of lines
SYNTAX
ALL [string target]
DESCRIPTION
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
DEFAULT
SEE ALSO
STATUS
Not Started
**man-end**********************************************************************/
#ifdef PROTO
int All(char *params)
#else
int All(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm1.c: All");
#endif
display_error(0,(char *)"This function has not yet been implemented");
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
backward - scroll backwards one screen
SYNTAX
BAckward [n|*]
DESCRIPTION
The BACKWARD command scrolls the file contents backwards through
the file [n|*] screens.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Does not support HALF or Lines options.
DEFAULT
With no parameters, 1 screen is scrolled.
SEE ALSO
forward,top
STATUS
Complete
**man-end**********************************************************************/
#ifdef PROTO
int Backward(char *params)
#else
int Backward(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
#define BAC_PARAMS 1
char *word[BAC_PARAMS+1];
char parm[BAC_PARAMS];
register int i;
unsigned short num_params;
long num_pages,num_lines;
unsigned short x,y;
int rc;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm1.c: Backward");
#endif
num_params = param_split(params,word,BAC_PARAMS,WORD_DELIMS,TEMP_PARAM);
if (num_params == 0)
{
num_params = 1;
word[0] = (char *)"1";
}
if (num_params != 1)
{
display_error(1,(char *)word[1]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
if (strcmp(word[0],"*") == 0)
{
CURRENT_VIEW->current_line = 0L;
post_process_line(CURRENT_VIEW->focus_line);
CURRENT_VIEW->focus_line = 0L;
pre_process_line(CURRENT_VIEW->focus_line);
if (!in_profile)
{
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
getyx(PREVIOUS_WINDOW,y,x);
else
getyx(CURRENT_WINDOW,y,x);
show_page();
y = get_row_for_focus_line(CURRENT_VIEW->current_row,
CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_line);
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
wmove(PREVIOUS_WINDOW,y,x);
else
wmove(CURRENT_WINDOW,y,x);
}
#ifdef TRACE
trace_return();
#endif
return(RC_TOF_EOF_REACHED);
}
if ((num_pages = atol(word[0])) == 0L)
{
display_error(4,(char *)word[0]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
num_lines = CURRENT_VIEW->current_line - ((CURRENT_SCREEN.rows-1)*